package com.zhz.order.interceptor;

import com.zhz.interceptor.IdempotentInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * @program: idempotent_token
 * @description: 启动了Mvc的配置
 * @author: zhanghz001
 * @create: 2021-03-15 08:46
 **/
// @Configuration
public class MvcConfigurer extends WebMvcConfigurerAdapter {
    @Autowired
    private IdempotentInterceptor idempotentInterceptor;
    
    @Bean
    public IdempotentInterceptor idempotentInterceptor() {
        return new IdempotentInterceptor();
    }
    
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(idempotentInterceptor);
        super.addInterceptors(registry);
    }
}
